<?php
/**
 * @version		$Id: banner.php 14401 2010-01-26 14:10:00Z louis $
 * @package		Joomla
 * @subpackage	Banners
 * @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

/**
 * @package		Joomla
 * @subpackage	Banners
 */
class TableHotel extends JTable
{
	/** @var int */
	var $id						= null;
	/** @var string */
	var $hotel_name				= null;
	/** @var string */
	var $star					= null;
	/** @var string */
	var $published				= null;
	/** @var string */
	var $checked_out			= null;
	/** @var string */
	var $ordering				= null;
	/** @var string */
	var $imageurl				= null;
	/** @var string */
	var $email1					= null; 
	/** @var string */
	var $email					= null;
	/** @var string */
	var $phone					= null; 
	/** @var string */
	var $phone1					= null;
	/** @var string */
	var $fax					= null;
	/** @var string */
	var $website				= null;
	/** @var string */
	var $address				= null;
	/** @var string */
	var $country_id				= null;
	/** @var string */
	var $city_id				= null;
	

	function __construct( &$_db )
	{
		parent::__construct( '#__hotels', 'id', $_db );
		
	}

	function clicks()
	{
		$query = 'UPDATE #__banner'
		. ' SET clicks = ( clicks + 1 )'
		. ' WHERE bid = ' . (int) $this->id
		;
		$this->_db->setQuery( $query );
		$this->_db->query();
	}

	/**
	 * Overloaded check function
	 *
	 * @access public
	 * @return boolean
	 * @see JTable::check
	 * @since 1.5
	 */
	function check()
	{
//		// check for valid client id
//		if (is_null($this->cid) || $this->cid == 0) {
//			echo "test";
//			$this->setError(JText::_( 'BNR_CLIENT' ));
//			return false;
//		}

		// check for valid name
		if(trim($this->hotel_name) == '') {
			$this->setError(JText::_( 'BNR_NAME' ));
			return false;
		}

//		if(empty($this->alias)) {
//			$this->alias = $this->hotel_name;
//		}
//		$this->alias = JFilterOutput::stringURLSafe($this->alias);

		/*if(trim($this->imageurl) == '') {
			$this->setError(JText::_( 'BNR_IMAGE' ));
			return false;
		}
		if(trim($this->clickurl) == '' && trim($this->custombannercode) == '') {
			$this->setError(JText::_( 'BNR_URL' ));
			return false;
		}*/

		return true;
	}
}
?>
